import { _decorator, Component, Node } from 'cc';
import { ssclass, sseffect } from '../state-signals';
import { account, userInfo } from '../store/user-info';
const { ccclass, property } = _decorator;

@ccclass('BtnView')
@ssclass
export class BtnView extends Component {
    nameC = 'btn_view';

    onLoad() {
        console.log('BtnView onLoad ...', this.node.uuid);
    }

    update(deltaTime: number) {
        
    }

    onClick() {
        Object.assign(userInfo, {
            name: '王五',
            age: userInfo.age + 1
        })

        userInfo.set((prev) => {
            prev.firend.age += 1
        });

        account.money += 5;
        account.coin++
    }

    @sseffect
    accEff() {
        console.log(account.money, "account.money")
    }

    @sseffect
    accEff2() {
        console.log(account.balance, "account.balance")
    }

    @sseffect
    firendeff() {
        console.log(userInfo.firend.age, "userInfo.firend.age")
    }
}

